home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS05.ADF
/
printer
/
render.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-01-15
|
3KB
|
76 lines
/*********************************************************************/
/* render.c AmigaLink 1/25/86 */
#include "exec/types.h"
#include "exec/nodes.h"
#include "exec/lists.h"
#include "exec/memory.h"
#include "devices/prtbase.h"
extern struct PrinterData *PD;
/* for the EPSON */
int Render(ct, x, y, status)
UBYTE ct; /* null for b/w printers */
UWORD x, y; /* the x & y co-ordinates */
/* or the pc & pr print values, or special */
UBYTE status; /* print status (0-init, 1-enter pixel, 2-dump) */
{
static UWORD ROWSIZE;
static UWORD BUFSIZE;
static UWORD bufptr;
UWORD i; /* mics. var */
BYTE err; /* the error # */
switch(status)
{
case 0 : /* alloc memory for printer buffer */
ROWSIZE=x; /* row size required for EPSON */
BUFSIZE=(6+ROWSIZE); /* buffer size required for EPSON */
PD->pd_PrintBuf = (UBYTE *)
AllocMem(BUFSIZE*2,MEMF_PUBLIC); /* alloc public mem */
if (err=(PD->pd_PrintBuf == 0)) return(err);
/* reset printer to power-up state */
if (err=(*(PD->pd_PWrite))("\033@",2)) return(err);
if (err=PWait(1,0)) return(err);
if (err=(*(PD->pd_PWrite))("\0331",2)) return(err); /* select 7/72 inch spacing */
bufptr=0;
return(0); /* flag all ok */
break;
case 1 : /* put pixel in buffer */
i = bufptr+x+4; /* calc which byte to use */
PD->pd_PrintBuf[i] = PD->pd_PrintBuf[i] | (1 << (7-(y&7))); /* fill print buffer */
return(0); /* flag all ok */
break;
case 2 : /* dump buffer to printer */
if (err=(*(PD->pd_PWrite))(&(PD->pd_PrintBuf[bufptr]), BUFSIZE)) return(err);
bufptr=BUFSIZE-bufptr;
return(0); /* flag all ok */
break;
case 3 : /* clear and init buffer */
for (i=bufptr; i<bufptr+BUFSIZE; i++)
PD->pd_PrintBuf[i] = 0; /* clear buffer */
PD->pd_PrintBuf[bufptr] = 27;
PD->pd_PrintBuf[bufptr+1] = 'L';
PD->pd_PrintBuf[bufptr+2] = ROWSIZE & 0xff;
PD->pd_PrintBuf[bufptr+3] = ROWSIZE >> 8;
PD->pd_PrintBuf[bufptr+BUFSIZE-2] = 10;
PD->pd_PrintBuf[bufptr+BUFSIZE-1] = 13;
return(0); /* flag all ok */
break;
case 4 : /* free the print buffer memory */
err=(*(PD->pd_PWrite))("\033@",2); /* reset printer to power-up state */
if (!err) err=(*(PD->pd_PBothReady))(); /* wait for both buffers to empty */
FreeMem(PD->pd_PrintBuf,BUFSIZE*2); /* free print buffer's memory */
return(err); /* return status */
break;
default:
return(0);
}
}